export const schema = {
    type: "page",
    title: "志愿时长管理",
    body: {
        type: "crud",
        api: "/api/reward-apply",
        filter: {
            title: "",
            panelClassName: 'no-bg no-border no-shadow no-padder m-b-sm',
            bodyClassName: "no-padder",
            submitText: "",
            controls: [
                {
                    type: "button-group",
                    btnActiveClassName: "btn-info active",
                    value: '0',
                    submitOnChange: true,
                    name: "status",
                    options: [
                        {
                            label: "全部",
                            value: ""
                        },
                        {
                            label: "待审核",
                            value: "0"
                        },
                        {
                            label: "通过",
                            value: "1"
                        },
                        {
                            label: "不通过",
                            value: "2"
                        }
                    ]
                }
            ]
        },
        bulkActions: [
            {
                type: "button",
                label: "通过",
                level: "success",
                actionType: "ajax",
                api: "/api/reward-apply/accept/${ids}"
            },

            {
                type: "button",
                label: "驳回",
                level: "danger",
                visibleOn: 'data.status != 1 && data.status != 2',
                actionType: "dialog",
                dialog: {
                    title: "批量不通过",
                    body: {
                        type: "form",
                        api: "/api/reward-apply/reject/${ids}",
                        controls: [
                            {
                                type: "text",
                                label: "驳回理由",
                                name: "reason"
                            }
                        ]
                    }
                }
            }
        ],
        columns: [
            {
                name: "name",
                label: "参加的项目",
                type: "tpl",
                tpl: "<a data-link='/project/view/${project.id}'>${project.name}</a>"
            },

            {
                type: "image",
                name: "attachment",
                label: "志愿证明图",
                multiple: true,
                imageWrapClassName: 'thumb-md m-b-xs m-r-xs',
                popOver: {
                    title: "",
                    body:
                    '<div class="w-xx-xxl"><% data.attachment && data.attachment.map(function(src) { %><img class="w-full m-b-sm" src="<%= src %>" /><% }) %></div>'
                }
            },


            {
                label: "姓名",
                name: "user.volunteer.real_name"
            },

            {
                label: "用户名",
                name: "user.username"
            },

            {
                label: "联系电话",
                name: "user.volunteer.phone"
            },
            {
                label: "申请时长",
                name: "reward_time"
            },
            {
                label: "已计入时长",
                name: 'work_time'
            },
            {
                label: "申请说明",
                name: 'content'
            },
            {
                label: "申请时间",
                name: "created_at",
                type: 'tpl',
                tpl: "${created_at|date:LL:YYYY-MM-DD HH:mm:ss}"
            },
            {
                label: "状态",
                name: "verify_status",
                type: "map",
                map: {
                    "0": "<span class='label label-warning'>待审核</span>",
                    "1": "<span class='label label-success'>已通过</span>",
                    "2": "<span class='label label-default'>已拒绝</span> ${verify_msg}",
                    "*": "${verify_status}"
                }
            }
        ]
    }
};
